import request from "@/utils/request";
import {IUserInfo, IWxLoginLog, UserListParams} from "./types/user";
import {IListParams} from "@/api/types/common";

// 获取用户信息
export const getUserInfo = (id:number) => {
  return request<IUserInfo>({
    method: 'GET',
    url: `/system/user/get/${id}`,
  })
}

// 保存用户
export const saveUserInfo = (user:IUserInfo) => {
  return request({
    method: 'POST',
    url: `/system/user/save`,
    data:user
  })
}

// 查询用户列表
export const getUserList = (page:UserListParams) => {
  return request<{
    total: number
    rows:IUserInfo[],
  }>({
    method: 'GET',
    url: `/system/user/list`,
    params:page
  })
}

export const deleteUser = (id: number) => {
  return request({
    method: 'DELETE',
    url: `/system/user/delete/${id}`
  })
}


export const getLoginCode = (id:string) => {
  return request<string>({
    method: 'GET',
    url: `/getLoginCode/${id}`,
  })
}

// 获取微信登录日志
export const queryWxLoginLogList = (params :IListParams) => {
  return request<{
    total: number
    rows:IWxLoginLog[],
  }>({
    method: 'GET',
    url: `/wx/queryWxLoginLogList`,
    params
  })
}